
package geneontofx;

import geneontofx.association.AssociationsModel;
import geneontofx.go.OntologyModel;
import geneontofx.sets.PopulationSet;
import geneontofx.sets.StudySet;
import geneontofx.statistics.Test;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuButton;
import javafx.scene.control.ToolBar;
import javafx.scene.control.TreeView;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;


public class Controller
    implements Initializable {

    @FXML //  fx:id="cardsPane"
    private StackPane cardsPane; // Value injected by FXMLLoader

    @FXML //  fx:id="mainMenuBar"
    private MenuBar mainMenuBar; // Value injected by FXMLLoader

    @FXML //  fx:id="mainToolBar"
    private ToolBar mainToolBar; // Value injected by FXMLLoader

    @FXML //  fx:id="optComboBox"
    private ComboBox<?> optComboBox; // Value injected by FXMLLoader

    @FXML //  fx:id="optionsLbl"
    private Label optionsLbl; // Value injected by FXMLLoader

    @FXML //  fx:id="projectBtn"
    private MenuButton projectBtn; // Value injected by FXMLLoader

    @FXML //  fx:id="treeView"
    private TreeView<?> treeView; // Value injected by FXMLLoader


    // Handler for ComboBox[fx:id="optComboBox"] onAction
    @FXML
    public void comboBoxChanged(ActionEvent event) {
        System.out.println(optComboBox.getSelectionModel().getSelectedItem());
    }

    // Handler for MenuItem[javafx.scene.control.MenuItem@2b36db45] onAction
    @FXML
    public void deleteProjBtnPressed(ActionEvent event) throws IOException {
        System.out.println("delete btn");
        OntologyModel ontology = OntologyModel.getOntologyInstance();
        ontology.parseOntology(null);
        ontology.remakeRelations();
        System.out.println("ontology done");
        
        AssociationsModel associations = AssociationsModel.getAssociationsModelInstance();
        associations.parseAssociations(null);
        System.out.println("associations done");
        
        StudySet stud = new StudySet();
        stud.readSetFile(null);
        stud.linkAssociations(associations);
        stud.linkOntoTerms(ontology);
        stud.countOntoTerms();
        System.out.println("study done");
        
        PopulationSet pop = new PopulationSet();
        pop.readSetFile(null);
        pop.linkAssociations(associations);
        pop.linkOntoTerms(ontology);
        pop.countOntoTerms();
        System.out.println("population done");
        
        Test basicTest = new Test(stud, pop);
        basicTest.performTest();
        
        System.out.println("done");
        

    }

    // Handler for MenuItem[javafx.scene.control.MenuItem@6ba91b2b] onAction
    @FXML
    public void newProjBtnPressed(ActionEvent event) throws IOException {
//        Stage stage = new Stage();
//        Parent root = FXMLLoader.load(getClass().getResource("NOWE OKNO.fxml"));
//        stage.setScene(new Scene(root));
//        stage.show();
        
    }

    @Override // This method is called by the FXMLLoader when initialization is complete
    public void initialize(URL fxmlFileLocation, ResourceBundle resources) {
        assert cardsPane != null : "fx:id=\"cardsPane\" was not injected: check your FXML file 'Gui.fxml'.";
        assert mainMenuBar != null : "fx:id=\"mainMenuBar\" was not injected: check your FXML file 'Gui.fxml'.";
        assert mainToolBar != null : "fx:id=\"mainToolBar\" was not injected: check your FXML file 'Gui.fxml'.";
        assert optComboBox != null : "fx:id=\"optComboBox\" was not injected: check your FXML file 'Gui.fxml'.";
        assert optionsLbl != null : "fx:id=\"optionsLbl\" was not injected: check your FXML file 'Gui.fxml'.";
        assert projectBtn != null : "fx:id=\"projectBtn\" was not injected: check your FXML file 'Gui.fxml'.";
        assert treeView != null : "fx:id=\"treeView\" was not injected: check your FXML file 'Gui.fxml'.";

        // initialize your logic here: all @FXML variables will have been injected

        
    }

}